package com.froggyware.tadpole.core;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: mst
 * Date: Sep 5, 2011
 * Time: 5:26:27 PM
 * To change this template use File | Settings | File Templates.
 */
public interface Migration {

    /**
     * This should see whether the observed data in the persistent store can be fit into
     * the given class with this migration. If it returns true it will be selected to run
     * and the migrate function must not throw any exception.
     * 
     * @param rawData
     * @param clazz
     * @return
     */
    public boolean accepts(Map<String, String> rawData, Class clazz);

    /**
     * Execute the migration on the given object. Result should be the mapped object,
     * maybe even executing other queries to form the data in the process.
     * The result will automatically be written back to disk by the code that
     * detected the incompatibility.
     *
     * @param rawData
     * @param clazz
     * @return
     */
    public Object migrate(Map<String, String> rawData, Class clazz);


}
